package com.neuedu.studentmanage.service.impl;

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.neuedu.studentmanage.entity.Classroom;
import com.neuedu.studentmanage.entity.Pager;
import com.neuedu.studentmanage.entity.Result;
import com.neuedu.studentmanage.mapper.ClassroomMapper;
import com.neuedu.studentmanage.service.ClassroomService;
@Service
@Transactional
public class ClassroomServiceImpl implements ClassroomService{
	@Autowired
	private ClassroomMapper classroomMapper;
	private Logger logger=Logger.getLogger(ClassroomServiceImpl.class);
	@Override
	public List<Classroom> findListByPager(Pager<Classroom> pager) {
		
		return classroomMapper.findListByPager(pager);
	}

	@Override
	public Integer findTotalByPager(Pager<Classroom> pager) {
		logger.info("findListByPager"+pager);
		return classroomMapper.findTotalByPager(pager);
	}

	@Override
	public Result add(Classroom object) {
		Result result=new Result(false, "教室新增失败！");
		boolean ret=classroomMapper.add(object);
		if (ret) {
			result=new Result(true, "教室新增成功！");
		}
		return result;
	}

	@Override
	public Result edit(Classroom object) {
		Result result=new Result(false, "教室信息修改失败！");
		boolean ret=classroomMapper.edit(object);
		if (ret) {
			result=new Result(true, "教室信息修改成功！");
		}
		
		return result;
	}

	@Override
	public Result deleteByIds(List<Classroom> ids) {
		Result result=new Result(false, "教室删除失败！");
		boolean ret=classroomMapper.deleteByIds(ids);
		if (ret) {
			result=new Result(true, "教室删除成功！");
		}
		return result;
	}

	@Override
	public List<Classroom> findAll() {
		
		return classroomMapper.findAll();
	}

}
